<?php defined('SYSPATH') or die('No direct script access.');

class AdminController extends Controller {

    public $listOrder = null;
    
    protected $defaultListOrder = null;

    public $wizardButtonsForm; // FormBuilder object with wizard buttons

    public function __construct($entityName = null) {
        parent::__construct();
        $this->entityName = $entityName;
    }

    public function getAuthAdmin($field=NULL) {
        $admin = $this->getSessionData()->getAuthAdmin();
        if ($field) {
            return $admin[$field];
        }
        return $admin;
    }
    public function setAuthAdmin($admin) {
        $this->getSessionData()->setAuthAdmin($admin);
    }

    public function quickSearch() {
        $formData = $this->postToDbValues();
        $id = $formData['quickSearch_id'];
        if (! valid::isId($id)) {
            $this->redirectToList('error.invalidId');
        }
        $this->redirect('/admin/' . $this->entityName . '/display?id=' . $id);
    }
}
